package main;

import java.net.ServerSocket;
import java.io.IOException;

/**
 * Created by IntelliJ IDEA.
 * User: qiukexu
 * Date: 2009-6-2
 * Time: 14:28:50
 */
public class ServerSocketFactory {
    public void runServer() {
        int clientCount = 0;
        ServerSocket serverSocket = null;
        try {
            serverSocket = new ServerSocket(ConfigReader.getBindPort());
            System.out.println("Socket Server Started At Port "+ConfigReader.getBindPort()+".");
            while (ConfigReader.isListenning()) {
                new ServerThread(serverSocket.accept(), clientCount).start();
                clientCount++;
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static void main(String[] args) {
        new ServerSocketFactory().runServer();
    }
}
